package com.example.statistics.ui.bank

import android.os.Bundle
import com.example.statistics.bean.DefineInputBean
import com.example.statistics.bean.IncomeExpenseBean
import com.example.statistics.common.BaseInputActivity
import com.example.statistics.net.UrlConfig
import com.example.statistics.utils.Constants
import com.example.statistics.utils.DefaultConfig
import com.example.statistics.weight.TextProcessingView

/**
 * 收入、支出
 */
class IncomeExpenseAddActivity : BaseInputActivity<IncomeExpenseBean>() {

    var purposeList = listOf<String>()
    var type = ""


    override val title: String
        get() = intent.getStringExtra(Constants.TITLE).orEmpty()

    override val url: String
        get() = UrlConfig.BANK_INCOME_EXPENSE_ADD


    override fun initialize() {
        super.initialize()
        if (title == DefaultConfig.FUNC_GENERAL_EXPENSE) {
            type = "支出"
            purposeList = DefaultConfig.BANK_EXPENSE_LIST
        } else {
            type = "收入"
            purposeList = DefaultConfig.BANK_INCOME_LIST
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        extentParams.add("type" to type)

    }

    override val inputDataList: List<DefineInputBean>
        get() = listOf(
            DefineInputBean("日期:", "data", TextProcessingView.STYLE_DATE, isNull = false),
            DefineInputBean("用途:", "purpose", TextProcessingView.STYLE_SELECTOR, isNull = false,
                singleDialog = Pair(purposeList) { str, _ ->
                    this.contentText = str
                }
            ),
            DefineInputBean("金额:", "money", TextProcessingView.STYLE_INPUT_FLOAT, isNull = false,
                afterTextChangeListener = { str, list ->
                    extentParams.add("balance" to str.toString())
                }),
            DefineInputBean("备注:", "remark", TextProcessingView.STYLE_INPUT),
        )


}